package com.rjs.nio.channel;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;

/**
 * UDP发送消息
 * @author LiuZhenghua
 * 2017年12月12日 下午4:01:21
 */
public class DatagramChannelClient {

	public static void main(String[] args) throws IOException {
		DatagramChannel datagramChannel = DatagramChannel.open();
		
		ByteBuffer byteBuffer = ByteBuffer.allocate(128);
		byteBuffer.put("hello world".getBytes());
		byteBuffer.flip();
		
		datagramChannel.send(byteBuffer, new InetSocketAddress("127.0.0.1", 9998));
	}
}
